package com.hdax.dmw.user.api.handlers;

import com.hdax.dmw.common.exceptions.MsgException;
import com.hdax.dmw.common.utils.Result;
import com.hdax.dmw.common.utils.ResultGenerator;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Component
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = {MsgException.class})
    public Result<String> msgExceptionHandler(MsgException e){
        return ResultGenerator.genErrorResult(e.getErrorCode(),e.getMessage());
    }

}
